﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CardGamesLibrary.Poker;

namespace CardGamesLibrary.UI.Poker
{
    public partial class Form1 : Form
    {
        private PokerPlayer _player = new PokerPlayer("Player 1", 1000, false);
        private PokerPlayer _player2 = new PokerPlayer("Player 2", 1000, false);
        private PokerPlayer _player3 = new PokerPlayer("Player 3", 1000, false);
        private PokerPlayer _player4 = new PokerPlayer("Player 4", 1000, false);
        private PokerPlayer _player5 = new PokerPlayer("Player 5", 1000, false);
        private PokerPlayer _player6 = new PokerPlayer("Player 6", 1000, false);
        private PokerPlayer _player7 = new PokerPlayer("Player 7", 1000, false);
        public Form1()
        {
            InitializeComponent();
           
            ResizeRedraw = true;
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void newTableToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PokerTable table = new PokerTable(10);
            var game = new TexasHoldemPokerGame(table);
            table.AddPlayer(_player, 200);
            table.AddPlayer(_player2, 200);
            table.AddPlayer(_player3, 200);
            table.AddPlayer(_player4, 200);
            table.AddPlayer(_player5, 200);
            table.AddPlayer(_player6, 200);
            table.AddPlayer(_player7, 200);
            var pt = new PokerTableForm(game) { MdiParent = this };
            pt.Show();
        }

        //protected override void OnPaint(PaintEventArgs e)
        //{
        //    e.Graphics.Clear(Color.Green);
        //    e.Graphics.FillRectangle(Brushes.Green,new Rectangle(e.ClipRectangle.Location,e.ClipRectangle.Size));
        //    if(_game.PokerTable != null)
        //    {

        //        //       *(10) *(D)   *(1)
        //        //   *                    *(2)
        //        //
        //        //   *                    *
        //        //       *     *     *
        //        var seatSize = 60;
        //        double screenWidth = Width;
        //        double left = screenWidth/8D;
        //        double screenHeigth = e.ClipRectangle.Height;
        //        double vcenter = (screenHeigth - (seatSize * 2)) / 3D;
        //        double vcenter2 = (screenHeigth - (seatSize * 2)) / 5D;

        //        // draw seat 9
        //        e.Graphics.DrawRectangle(Pens.Blue, new Rectangle((int) (left - (seatSize / 2)), (int) vcenter, seatSize, seatSize));
                
        //        // draw seat 2
        //        e.Graphics.DrawRectangle(Pens.Blue, new Rectangle((int) (screenWidth - left - (seatSize )), (int) vcenter, seatSize, seatSize));

        //        // draw seat 8
        //        e.Graphics.DrawRectangle(Pens.Blue, new Rectangle((int) (left - (seatSize / 2)), (int) (screenHeigth - seatSize - vcenter), seatSize, seatSize));
                
        //        // draw seat 3
        //        e.Graphics.DrawRectangle(Pens.Red, new Rectangle((int) (screenWidth - left - (seatSize )), (int) (screenHeigth - seatSize - vcenter), seatSize, seatSize));

        //        var wi = ((int)(screenWidth - left - (seatSize*2))) - (int)(left - (seatSize / 2)) - (seatSize*3);
        //        // draw seat 10 Dealer and 1
        //        for (int i = 1; i <= 3; i++)
        //        {

        //            e.Graphics.DrawRectangle(Pens.Red, new Rectangle(((int)left + (i * (wi / 3))), (int)(screenHeigth - seatSize - vcenter2), seatSize, seatSize));
                    
                    
        //            e.Graphics.DrawRectangle(Pens.Red, new Rectangle(((int)left + (i * (wi / 3))), (int)( vcenter2-seatSize), seatSize, seatSize));


        //        }
               
        //        // Todo : Improve logic and drawing use controls !
        //    }
           
           
        //}
        
    }
}
